import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDERBase } from '../der/ipsderbase';
import { IPSDEDQGroupCondition } from './ipsdedqgroup-condition';
import { IPSDEDQJoin } from './ipsdedqjoin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEDQJoinImpl extends PSModelObjectImpl implements IPSDEDQJoin {
  get alias(): string {
    return this.M.alias;
  }

  protected childpsdedqjoins: IPSDEDQJoin[] | null = null;

  getChildPSDEDQJoins(): IPSDEDQJoin[] | null {
    if (this.childpsdedqjoins == null) {
      this.childpsdedqjoins = this.fillChildListModel(this.M.getChildPSDEDQJoins, 'dataentity.ds.IPSDEDQJoin') as IPSDEDQJoin[];
    }
    return this.childpsdedqjoins;
  }

  get childPSDEDQJoins(): IPSDEDQJoin[] | null {
    return this.getChildPSDEDQJoins();
  }

  findChildPSDEDQJoin(objKey: any): IPSDEDQJoin | null {
    return this.getPSModel5('dataentity.ds.IPSDEDQJoin', this.getChildPSDEDQJoins(), objKey) as IPSDEDQJoin;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  protected derpsdataentity: IPSDataEntity | null = null;

  getDERPSDataEntity(): IPSDataEntity | null {
    if (this.derpsdataentity != null) return this.derpsdataentity;
    const value = this.M.getDERPSDataEntity;
    if (value == null) {
      return null;
    }
    this.derpsdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getDERPSDataEntity') as IPSDataEntity;
    return this.derpsdataentity;
  }

  get dERPSDataEntity(): IPSDataEntity | null {
    return this.getDERPSDataEntity();
  }

  getDERPSDataEntityMust(): IPSDataEntity {
    const value = this.getDERPSDataEntity();
    if (value == null) {
      throw new Error('未指定连接关系所在实体');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected joinpsder: IPSDERBase | null = null;

  getJoinPSDER(): IPSDERBase | null {
    if (this.joinpsder != null) return this.joinpsder;
    const value = this.M.getJoinPSDER;
    if (value == null) {
      return null;
    }
    this.joinpsder = this.getDERPSDataEntityMust().findMinorPSDERBase(value);
    return this.joinpsder;
  }

  get joinPSDER(): IPSDERBase | null {
    return this.getJoinPSDER();
  }

  getJoinPSDERMust(): IPSDERBase {
    const value = this.getJoinPSDER();
    if (value == null) {
      throw new Error('未指定连接实体关系');
    }
    return value;
  }

  protected joinpsdataentity: IPSDataEntity | null = null;

  getJoinPSDataEntity(): IPSDataEntity | null {
    if (this.joinpsdataentity != null) return this.joinpsdataentity;
    const value = this.M.getJoinPSDataEntity;
    if (value == null) {
      return null;
    }
    this.joinpsdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getJoinPSDataEntity') as IPSDataEntity;
    return this.joinpsdataentity;
  }

  get joinPSDataEntity(): IPSDataEntity | null {
    return this.getJoinPSDataEntity();
  }

  getJoinPSDataEntityMust(): IPSDataEntity {
    const value = this.getJoinPSDataEntity();
    if (value == null) {
      throw new Error('未指定连接实体对象');
    }
    return value;
  }

  get joinType(): string {
    return this.M.joinType;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdedqgroupcondition: IPSDEDQGroupCondition | null = null;

  getPSDEDQGroupCondition(): IPSDEDQGroupCondition | null {
    if (this.psdedqgroupcondition != null) return this.psdedqgroupcondition;
    const value = this.M.getPSDEDQGroupCondition;
    if (value == null) {
      return null;
    }
    this.psdedqgroupcondition = this.getPSModel4('dataentity.ds.IPSDEDQGroupCondition', value, 'getPSDEDQGroupCondition') as IPSDEDQGroupCondition;
    return this.psdedqgroupcondition;
  }

  get psDEDQGroupCondition(): IPSDEDQGroupCondition | null {
    return this.getPSDEDQGroupCondition();
  }

  getPSDEDQGroupConditionMust(): IPSDEDQGroupCondition {
    const value = this.getPSDEDQGroupCondition();
    if (value == null) {
      throw new Error('未指定查询条件对象');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSDEDQJoinImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.ds.IPSDEDQJoin') return true;
    return super.instanceof(cls);
  }
}
